<template>
  <div class="year-container">
    <div class="year-title">
      <p>年度客流量对比</p>
      <img src="../../images/dataScreen-title.png" alt="暂无图片" />
    </div>
    <div ref="yearRef" class="year-echart"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import * as echarts from "echarts";
let yearRef = ref();
onMounted(() => {
  const myEchart = echarts.init(yearRef.value);
  myEchart.setOption({
    title: {
      text: "年度统计(散点图)",
      textStyle: {
        color: "white",
        fontSize: 16,
      },
      left: "45%",
    },
    xAxis: {
      show: true,
      type: "category",
    },
    yAxis: {
      show: false,
    },
    grid: {
      top: 30,
      left: 20,
      right: 20,
      bottom: 30,
    },
    series: [
      {
        type: "scatter", // 散点图
        data: [33, 88, 9, 788, 234, 123, 674, 88, 33, 888, 332, 123, 675, 8],
        symbol: "arrow", // 显示的图标
        symbolSize: 16,
        // 图文标签
        label: {
          show: true,
          position: "top",
          color: "skyblue",
        },
        itemStyle: {
          color: {
            // 渐变颜色的配置
            type: "linear",
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0,
                color: "black", // 0%处的颜色
              },
              {
                offset: 1,
                color: "blue", // 100%处的颜色
              },
            ],
            global: false, // 缺省为 false
          },
        },
      },
    ],
  });
});
</script>

<style scoped lang="scss">
.year-container {
  flex: 1;
  background: url("../../images/dataScreen-main-rb.png") no-repeat;
  background-size: 100% 100%;
  margin: 10px 0px;
  .year-title {
    color: white;
    font-size: 20px;
  }
  .year-echart {
    width: 100%;
    height: calc(100% - 40px);
  }
}
</style>
